package br.com.reobotenet.model.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public class JPAUtil {
	//fabrica
	protected static EntityManagerFactory entityManagerFactory;
	//gerenciador de entidade
	protected static EntityManager  em;
    //Executa apenas a primeira
    static {
    	//instanciando a frabrica
    	entityManagerFactory = Persistence
    	.createEntityManagerFactory("persistence-unit");
    	//instanciando o gerenciador
    	em = entityManagerFactory.createEntityManager();
    }
    /**
     * Método que retorna um objeto EntityManager
     * @return
     */
    public static EntityManager abreConexao(){
    	return em;
    }
}


